Imports CapaDeDatos
Public Class nCliente
    Private Cliente As CapaDeDatos.dCliente = New CapaDeDatos.dCliente()
    Private Localidad As CapaDeDatos.dLocalidad = New CapaDeDatos.dLocalidad
    Private Categoria As CapaDeDatos.dCategoriaFiscal = New CapaDeDatos.dCategoriaFiscal
    Private Condicion As CapaDeDatos.dCondicion = New CapaDeDatos.dCondicion
    Public Function Listar(ByVal CodigoCliente As String, _
                                    ByVal RazonSocial As String, _
                                    ByVal Cuit As String, _
                                    ByVal Direccion As String, _
                                    ByVal TelCel As String, _
                                    ByVal Mail As String, _
                                    ByVal CondicionVenta As String, _
                                    ByVal CodigoLocalidad As String, _
                                    ByVal CodigoCategoria As String, _
                                    ByVal FechaAlta As String, _
                                    ByVal FechaAltaMax As String, _
                                    ByVal FechaAltaMin As String) As DataSet
        Dim DtsPrincipal As DataSet
        DtsPrincipal = Cliente.BuscarFiltrado(CodigoCliente _
                                    , RazonSocial _
                                    , Cuit _
                                    , Direccion _
                                    , TelCel _
                                    , Mail _
                                    , CondicionVenta _
                                    , CodigoLocalidad _
                                    , CodigoCategoria _
                                    , FechaAlta _
                                    , FechaAltaMax _
                                    , FechaAltaMin)

        DtsPrincipal.Tables(0).Columns.Add("Nombre")
        DtsPrincipal.Tables(0).Columns.Add("Detalle")
        DtsPrincipal.Tables(0).Columns.Add("Descripcion")
        Dim I As Integer

        For I = 0 To DtsPrincipal.Tables(0).Rows.Count - 1
            Try
                DtsPrincipal.Tables(0).Rows(I)("Nombre") = Localidad.ListarNombres(DtsPrincipal.Tables(0).Rows(I)("CodigoLocalidad").ToString(), "").Tables(0).Rows(0)("Nombre").ToString()
            Catch ex As Exception
                DtsPrincipal.Tables(0).Rows(I)("Nombre") = "Nombre No Registrado"
            End Try

            Try
                DtsPrincipal.Tables(0).Rows(I)("Detalle") = Categoria.BuscarFiltrado(DtsPrincipal.Tables(0).Rows(I)("CodigoCategoria").ToString(), "").Tables(0).Rows(0)("Detalle").ToString()
            Catch ex As Exception
                DtsPrincipal.Tables(0).Rows(I)("Detalle") = "Nombre No Registrado"
            End Try

            Try
                DtsPrincipal.Tables(0).Rows(I)("Descripcion") = Condicion.ListarNombres(DtsPrincipal.Tables(0).Rows(I)("CondicionVenta").ToString(), "").Tables(0).Rows(0)("Descripcion").ToString()
            Catch ex As Exception
                DtsPrincipal.Tables(0).Rows(I)("Descripcion") = "Verificar..."
            End Try
        Next

        Return DtsPrincipal
    End Function
    Public Function Existe(ByVal Cuit As String) As Boolean
        Return Cliente.Existe(Cuit)
    End Function
    Public Function Insertar(ByVal RazonSocial As String, _
                            ByVal Cuit As String, _
                            ByVal Direccion As String, _
                            ByVal TelCel As String, _
                            ByVal Mail As String, _
                            ByVal CondicionVenta As String, _
                            ByVal CodigoLocalidad As String, _
                            ByVal CodigoCategoria As String) As Boolean
        Cliente.Insertar(RazonSocial, _
                        Cuit, _
                        Direccion, _
                        TelCel, _
                        Mail, _
                        CondicionVenta, _
                        CodigoLocalidad, _
                        CodigoCategoria)
    End Function
    Public Function Eliminar(ByVal CodigoCliente As String) As Boolean
        Return Cliente.Eliminar(CodigoCliente)
    End Function
    Public Function Modificar(ByVal CodigoCliente As String, _
                                ByVal RazonSocial As String, _
                                ByVal Cuit As String, _
                                ByVal Direccion As String, _
                                ByVal TelCel As String, _
                                ByVal Mail As String, _
                                ByVal CondicionVenta As String, _
                                ByVal CodigoLocalidad As String, _
                                ByVal CodigoCategoria As String) As Boolean
        Return Cliente.Modificar(CodigoCliente, _
                                    RazonSocial, _
                                    Cuit, _
                                    Direccion, _
                                    TelCel, _
                                    Mail, _
                                    CondicionVenta, _
                                    CodigoLocalidad, _
                                    CodigoCategoria)
    End Function

End Class
